<?php

namespace app\index\model\tan;
use think\Model;
use think\Session;
class business extends Model
{
//    private $
    protected $type = [
        'is_auth'    =>  'int',
    ];
    /**
     * 显示一个店铺
     * @param int $id 店铺id
     */
    public function showone($id){
        return $this->where(['id'=>$id ]) ->find();
    }
    /**
     * root
     * 认证店铺
     * @param type $id
     * @param type $data
     * @return type
     */
    public function up($id,$data){
        return $this->where(['id'=>$id] ) ->update([
            "is_auth"=>@$data['is_auth'] == 0 ? 0:1,
            "state"=>@$data['state']== 0 ? 0:1,
        ]);
    }
    
    /**
     * 保存添加的店铺
     * @param type $data
     */
    public function savebusiness($data,$mobile){
        $data['business_phone']=$mobile;
        $data['business_id']=Session::get("user.id");
        $data['createtime']=date("Y-m-d H:i:s");
        return $this->insert($data);
    }
    /**
     * 列表
     * @param type $userid  用户id
     * @return type
     */
    public function showlist($userid){
        return $this->where([
            "business_id"=>$userid,
        ])->paginate();
    }
}
